﻿{extend name="$index_style_layout" /}
{block name="head_title"}购买广告{/block}

{block name="body_content"}
<link rel="stylesheet" href="__STATIC__/group/list.css">	
<div class="MainContainer ShowContentType">
	<div class="ShowTypes">
		<a href="#">最多粉丝</a>
		<a href="#">最多贴子</a>
		<a href="#">最高人气</a>
	</div>
	<div class="ListBox">
	{qb:tag name="qun_wap_ad_index" type="qun" by="desc" where="openad<>0" union="order" order="usernum" rows="8"}
		<div class="list">
			<ul>
				<li class="img"><a href="{$rs.url}"><img src="{$rs.picurl}" onerror="this.src='__STATIC__/images/nopic.png'"><span style="display:none;" class="num{$i}">{$i}</span></a></li>
				<li class="info">
					<div class="title"><a href="{$rs.url}">{$rs.title}</a></div>
					<div class="cnt"><!--{$rs.content|get_word=200}-->
						{php}$adset=fun("qun@adset_status",$rs['id']);{/php}
						{$adset.price}元/{$adset.day}天 生效:{$adset.time|format_time="m-d H:i"}
					</div>
					<div class="other">
						<span><i class="fa fa-user-o">{$rs.usernum}</i></span>
						<em><i class="fa fa-file-text-o">{:fun('qun@count','bbs_content1',$rs.id)}</i></em>
						<em><i class="si si-fire">{$rs.view}</i></em>
					</div>
				</li>
				<li class="join"><a href="{:murl('qun/aduser/add',['aid'=>$rs['id']])}">购买</a></li>
			</ul>
		</div>
	{/qb:tag}
	</div>
	<div class="ListBox"></div>
	<div class="ListBox"></div>
</div>	

<script type="text/javascript">
var choose_i = 0; //选中第几项
var haveshowpage = []; //每一项,作个标志,已经已显示到第几页
var orders = ['usernum','replynum','view'];
//显示更多
function showMoreContent(){	
	var url = '{qb:url name="qun_wap_ad_index" /}' + haveshowpage[choose_i] + '&order=' + orders[choose_i] ;	//第几项对应的网址	
	$.get(url,function(res){
		if(res.code==0){
			if(res.data==''){
				layer.msg("已经显示完了！",{time:500});
			}else{
				if(haveshowpage[choose_i]==1){
					$('.ShowContentType .ListBox').eq(choose_i).html(res.data);
				}else{
					$('.ShowContentType .ListBox').eq(choose_i).append(res.data);
				}
				haveshowpage[choose_i]++;
				scroll_get = true;
			}
		}else{
			layer.msg(res.msg,{time:2500});
		}
	});
	
	
}

//切换显示
function showContentType(num){
	choose_i = num;
	$('.ShowContentType .ShowTypes a').removeClass('ck');
	$('.ShowContentType .ShowTypes a').eq(num).addClass('ck');
	$('.ShowContentType .ListBox').hide();
	$('.ShowContentType .ListBox').eq(num).show();

	if(typeof haveshowpage[choose_i] == 'undefined'){
		haveshowpage[choose_i] = 1;
		showMoreContent();
	}
}

$('.ShowContentType .ShowTypes a').click(function(){
	var thisnum=$(this).index();
	showContentType(thisnum);
});
showContentType( {:intval(input('type'))} );


//滚动显示更多
var scroll_get = true;	//做个标志,不要反反复复的加载
$(document).ready(function () {
	$(window).scroll(function () {
		if (scroll_get==true &&  (400 + $(window).scrollTop())>($(document).height() - $(window).height())) {
			scroll_get = false;			
			layer.msg('内容加截中,请稍候',{time:1500});
			showMoreContent();
		}
	});
});

</script>

{/block}